/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.pa036.kiss.Entity;

/**
 *
 * @author Vasa
 */
public class PokojDTO {

  private Long id;
  private int pocet_luzek;
  private int pohlavi;
  private int cislo_pokoje;
  private Double cena_za_luzko;
  private int pocet_volnych_luzek;
  private KolejDTO kolej;

  public Long getId () {

    return this.id;
  }

  public PokojDTO setId ( final Long id ) {

    if ( id != null ) {

      this.id = new Long ( id.longValue () );
    }

    return this;
  }

    public int getPocet_luzek() {
        return pocet_luzek;
    }

    public void setPocet_luzek(int pocet_luzek) {
        this.pocet_luzek = pocet_luzek;
    }

    public int getCislo_pokoje() {
        return cislo_pokoje;
    }

    public void setCislo_pokoje(int cislo_pokoje) {
        this.cislo_pokoje = cislo_pokoje;
    }

    public int getPocet_volnych_luzek() {
        return pocet_volnych_luzek;
    }

    public void setPocet_volnych_luzek(int pocet_volnych_luzek) {
        this.pocet_volnych_luzek = pocet_volnych_luzek;
    }

    public KolejDTO getKolej() {
        return kolej;
    }

    public void setKolej(KolejDTO kolej) {
        this.kolej = kolej;
    }

    public int getPohlavi() {
        return pohlavi;
    }

    public void setPohlavi(int pohlavi) {
        this.pohlavi = pohlavi;
    }

    public Double getCena_za_luzko() {
        return cena_za_luzko;
    }

    public void setCena_za_luzko(Double cena_za_luzko) {
        this.cena_za_luzko = cena_za_luzko;
    }
  
  

  @Override
  public boolean equals ( final Object rhs ) {

    if ( this == rhs ) return true;

    if ( rhs == null ) return false;

    if ( this.getClass () != rhs.getClass () ) return false;

    final PokojDTO c = (PokojDTO) rhs;

    return this.id == null ? c.id == null : this.id.equals ( c.id ) &&
        this.kolej == null ? c.kolej == null : this.kolej.equals ( c.kolej ) &&
        this.pocet_luzek == c.pocet_luzek &&
        this.pohlavi == c.pohlavi &&
        this.cislo_pokoje == c.cislo_pokoje &&
        this.pocet_volnych_luzek == c.pocet_volnych_luzek &&
        this.cena_za_luzko == null ? c.cena_za_luzko == null : this.cena_za_luzko.equals ( c.cena_za_luzko );
    
  }

  @Override
  public int hashCode () {

    final int[] hashCodes = {
        (this.id == null) ? 0 : this.id.hashCode (),
        (this.kolej == null) ? 0 : this.kolej.hashCode (),
        (this.cena_za_luzko == null) ? 0 : this.cena_za_luzko.hashCode (),
        this.pocet_luzek,
        this.cislo_pokoje,
        this.pohlavi,
        this.pocet_volnych_luzek,
    };

    int hash = 17;
    for ( final int currentHashCode: hashCodes ) {

      hash = hash * 31 + currentHashCode;
    }

    return hash;
  }

  @Override
  public Object clone () {

    try {

      return ( (PokojDTO) super.clone () ).setId ( this.id );
    } catch ( CloneNotSupportedException ex ) {

      assert false: "CloneNotSupportedException thrown";
      return null;
    }
  }

  @Override
  public String toString () {

    return this.id + ": " + this.cislo_pokoje + " has " + this.pocet_luzek
        + " capacity and" + this.pocet_volnych_luzek + " one for" + this.cena_za_luzko.toString()
    ;
  }

  /**
   * Determine whether the person has set necessary information
   */
  public void checkState () {

    final boolean noCisloPokoje = this.cislo_pokoje == 0;
    final boolean noCenaZaLuzko = this.cena_za_luzko == 0;
    final boolean noPocetLuzek = this.pocet_luzek == 0;

    if ( noCisloPokoje && noCenaZaLuzko && noPocetLuzek)  {

      throw new IllegalStateException ( "Cislo pokoje, cena za luzko a pocet obsazenych musi byt nastaveny" );
    }
  }
}
